<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		
		<button id="write">写入</button>
		
		<script type="text/javascript" src="../js/convert.js" ></script>
		<script>
			
			function doSave(value, type, name) {
	            var blob;
	            if (typeof window.Blob == "function") {
	                blob = new Blob([value], {type: type});
	            } else {
	                var BlobBuilder = window.BlobBuilder || window.MozBlobBuilder || window.WebKitBlobBuilder || window.MSBlobBuilder;
	                var bb = new BlobBuilder();
	                bb.append(value);
	                blob = bb.getBlob(type);
	            }
	            var URL = window.URL || window.webkitURL;
	            var bloburl = URL.createObjectURL(blob);
	            var anchor = document.createElement("a");
	            if ('download' in anchor) {
	                anchor.style.visibility = "hidden";
	                anchor.href = bloburl;
	                anchor.download = name;
	                document.body.appendChild(anchor);
	                var evt = document.createEvent("MouseEvents");
	                evt.initEvent("click", true, true);
	                anchor.dispatchEvent(evt);
	                document.body.removeChild(anchor);
	            } else if (navigator.msSaveBlob) {
	                navigator.msSaveBlob(blob, name);
	            } else {
	                location.href = bloburl;
	            }
	        }
 
        let test = '1234567中国89';
        
        console.log(test);
        
        document.getElementById("write").onclick = () => {
        	//执行写入
        	doSave(test, "text/latex", "hello.txt");
        	
        }
        
		</script>
		
	</body>
</html>
